<template></template>

<script>
import Vue from 'vue'
import { Dialog } from 'vant'
import { enterUserSetPayPassword } from '_projectFn/page'

export default {
    name: 'NeedSetPayPwd',
    props: {
        message: {
            type: String,
            default: '请设置支付密码！',
        },
        cancelButtonText:  {
            type: String,
            default: '取消',
        },
        confirmButtonText:  {
            type: String,
            default: '设置支付密码',
        },
        title:  {
            type: String,
            default: '',
        },
        width: {
          type: Number,
          default: 280,  
        },
        isShow: {
            type: Boolean,
            default: false
        },
        closeOnClickOverlay: {
            type: Boolean,
            default: true
        }
    },
    watch: {
        isShow() {
            const that = this
            if (this.isShow) {
                Dialog.alert({
                    message: this.message,
                    title: this.title,
                    confirmButtonText: this.confirmButtonText,
                    cancelButtonText: this.cancelButtonText,
                    width: this.width,
                    closeOnClickOverlay: this.closeOnClickOverlay,
                    beforeClose(action, done) {
                        // console.log('action', action)
                        that.$emit('closeNeedSetPayPwdWindow')
                        done()
                    }
                }).then(() => {
                    // console.log('点击设置支付密码')
                    enterUserSetPayPassword()
                })
            } else {
                Dialog.close()
            }
        }
    },
    deactivated() {
        Dialog.close()
    },
}
</script>